package com.by.utils;

import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class FactoryUtils {

    private static SqlSessionFactory factory;

    static {
        //读取mybaits-config.xml文件
        InputStream is = FactoryUtils.class.getClassLoader().getResourceAsStream("mybatis-config.xml");
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        factory = builder.build(is);
    }

    public static SqlSessionFactory getFactory() {
        return factory;
    }
}
